import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
	name: 'getStatus',
})
export class GetStatusPipe implements PipeTransform {
	transform(value: string, args?: any): string {
		switch (value) {
			case 'Y':
				return '激活';
			case 'N':
				return '未激活';
		}
	}
}
@Pipe({
	name: 'getUserStatus',
})
export class GetUserStatusPipe implements PipeTransform {
	transform(isActive: string, status: string, args?: any): string {
		switch (isActive) {
			case 'Y':
				console.log(isActive, status);
				let type;
				status == 'Y' ? (type = '已激活') : (type = '已冻结');
				return type;
			case 'N':
				return '未激活';
		}
	}
}

@Pipe({
	name: 'getOrderStatus',
})
export class GetOrderStatusPipe implements PipeTransform {
	transform(value: string, args?: any): string {
		switch (value) {
			case 'Y':
				return '已支付';
			case 'N':
				return '未支付';
			case 'PENDING':
				return '待支付';
			case 'CANCELED':
				return '已取消';
			case 'REJECTED':
				return '被拒绝';
			case 'EXPIRED':
				return '订单过期';
			case 'PAID':
				return '方案设计中';
			case 'PREPARING':
				return '行程已告知';
			case 'COMPLETED':
				return '订单完成';
			case 'RECEIVED':
				return '接单';
		}
	}
}

@Pipe({
	name: 'getTansactionStatus',
})
export class GetTransactionStatusPipe implements PipeTransform {
	transform(value: string, args?: any): string {
		if (args[value]) {
			return args[value];
		}
		return '';
	}
}
@Pipe({
	name: 'menuLanguage',
})
export class MenuLanguagePipe implements PipeTransform {
	transform(value: string, args?: any): string {
		if (value) {
			const name = JSON.parse(value);
			const lan = localStorage.getItem('lang');
			switch (lan) {
				case 'zh':
					args = 'zh_CN';
					break;
				case 'en':
					args = 'en_US';
					break;
				case 'jp':
					args = 'ja_JP';
					break;
				default:
					args = 'zh_CN';
					break;
			}
			return name[args];
		} else {
			return null;
		}
	}
}
